package Group5_Project2;

/*Group members:
 * Carl Michael
 * Brandon Mefford
 * Kyle Reinhardt
 * Greg Vissing
 */

/* 1. A Hashcode is a number generated from any object. You should override the hashCode method, whenever the equals method is overridden
 *  to ensure that two equal objects return the same hash code. The general contract for overridden 
 * implementations of this method is that they behave in a way consistent with the same object's equals() 
 * method: that a given object must consistently report the same hash value **(unless it is changed so 
 * that the new version is no longer considered "equal" to the old), and that two objects which equals() 
 * says are equal must report the same hash value.
 */

//Question #2: it is unnecessary to override Employee.equals(Object), it inherits the correct method from Person class

public class Project2 {
	public static void main(String[] args) {
		Project2 Core = new Project2();
		Person p1 = Core.new Person("Billy", "Hill", "12");
		Person p2 = Core.new Person("Dumpty","Humpty","34");
		Student s1 = Core.new Student("Michael","Carl","56","stu12",4.0,"someProf");
		Student s2 = Core.new Student("Derp","Herp","78","stu34",2.0,"Prof2");
		Employee e1 = Core.new Employee("Nye","Bill","90","emp12",30000,"SrEmp"); //ID salary super, str double str
		Employee e2 = Core.new Employee("Dude","Some","34","emp34",35000,"SrEmp2");
	}
	public class Person{
		String lastName;
		String firstName;
		private String SSN;
		public Person(String lName, String fName, String social){
			lastName = lName;
			firstName = fName;
			SSN = social;
		}
		protected String getSSN() {
			return SSN;
		}
		@Override
		public boolean equals(Object p){
			if (p.getClass()==Person.class){
				if (this.SSN == ((Person)p).getSSN()){
					return true;
				}
			}
			return false;
		}
		@Override
		public String toString(){
			return (this.lastName+"\n"+this.firstName+"\n"+this.getSSN());
		}
		@Override
		public int hashCode(){
			return this.SSN.hashCode();
		}
	}
	public class Student extends Person{
		private String studentID;
		private double GPA;
		String advisor;
		public Student(String lName, String fName, String social, String ID, double grade, String adv) {
			super(lName, fName, social);
			studentID = ID;
			GPA = grade;
			advisor = adv;
		}
		protected double getGPA() {
			return GPA;
		}
		protected void setGPA(double gPA) {
			GPA = gPA;
		}
		protected String getStudentID() {
			return studentID;
		}
		@Override
		public boolean equals(Object p){
			if (p.getClass() == Student.class){
				if (this.studentID == ((Student)p).getStudentID()){
					return true;
				}
			}
			return false;
		}
		@Override
		public String toString(){
			return (this.lastName+"\n"+this.firstName+"\n"+this.getSSN()+"\n"+this.studentID+"\n"+this.GPA+"\n"+this.advisor);
		}
		@Override
		public int hashCode(){
			return this.studentID.hashCode();
		}
	}
	public class Employee extends Person{
		String employeeID;
		private double salary;
		String supervisor;
		public Employee(String lName, String fName, String social, String ID, double sal, String visor) {
			super(lName, fName, social);
			employeeID = ID;
			salary = sal;
			supervisor = visor;
		}
		protected double getSalary() {
			return salary;
		}
		protected void setSalary(double salary) {
			this.salary = salary;
		}
		@Override
		public String toString(){
			return (this.lastName+"\n"+this.firstName+"\n"+this.getSSN()+"\n"+this.employeeID+"\n"+this.getSalary()+"\n"+this.supervisor);
		}
	}
}